<template>
	<view class="list">
		<view class="listbg" :style="{'background-image':'url('+playlist.coverImgUrl+')'}"></view>
		<!-- 顶部样式 -->
			<mucishead title="歌单" :icon="true" color="#fff"></mucishead>
			<!-- 列表滚动区域 -->
		<view class="container" v-show="!isLoading">
			<scroll-view scroll-y="true" >
				<!-- 头部描述区域 -->
				<view class="list-head">
					<!-- 左边图片区域 -->
					<view class="list-head-img">
						<image :src="playlist.coverImgUrl"mode=""></image>
						<text class="iconfont icon-movie">{{playlist.playCount | formatCount}}</text>
					</view>
					<!-- 右边文字区域 -->
					<view class="list-head-text">
						<view class="">{{playlist.name}}</view>
						<view class=""><image :src="playlist.creator.avatarUrl"></image>{{playlist.creator.nickname}}</view>
						<view class="">{{playlist.description}}</view>
					</view>
				</view>
				
					<!-- 平台差异化布局 微信分享按钮只在微信展示 -->
				<!-- #ifdef MP-WEIXIN -->
				<button class="list-share" open-type="share">
				<svg class="icon icon-share" aria-hidden="true">
				    <use xlink:href="#icon-turnvoice"></use>
				</svg>
				<text>分享给微信好友</text>
				</button>
				<!-- #endif -->
				
				<!-- 歌单列表区域 -->
						
				<view class="list-music">
					<!-- 歌单列表头部 -->
					<view class="list-music-head">
						<text class="iconfont icon-timeout"></text>
						<text>播放全部</text>
						<text>(共{{playlist.trackCount}}首)</text>
					</view>
					
					<!-- 歌单列表内容 -->
					<!-- <view class="list-music-item">
							<view class="list-music-top">1</view>
							<view class="list-music-song">
								<view class="">与我无关</view>
								<view class="">
									冗-与我无关
								</view>
							</view>
							<text class="iconfont icon-timeout itemiconfont"></text>
					</view> -->
					
					<view class="list-music-item" v-for="(item,index) in playlist.tracks" :key='index' @tap="handelToDetail(item.id)">
							<view class="list-music-top">{{index+1}}</view>
							<view class="list-music-song">
								<view class="">{{item.name}}</view>
								<view class="">
									
								<!-- 	v-if="privileges[index].flag > 60 && privileges[index].flag < 70 "
									 v-if="privileges[index].maxbr == 999000" -->
									<image  src="../../static/images/dujia.png" ></image>
									<image  src="../../static/images/sq.png"></image>
									{{item.ar[0].name}} - {{item.name}}
								</view>
							</view>
							<text class="iconfont icon-timeout itemiconfont"></text>
					</view>
				</view>	
			</scroll-view>
			
			</view>
	</view>
</template>

<script>
	// 导入公共头部文件
	import mucishead from '../../components/mucishead/mucishead.vue'
	// 导入icon样式表
	import '@/common/iconfont.css'
	// 导入接口文件
	import {list} from '../../common/api.js'
	
	export default {
		data() {
			return {
				playlist:{
					// 歌单人物图
					creator:{
						avatarUrl:'',
					},
					// 背景图or歌单图
					coverImgUrl:'',
					//歌单数量
					trackCount:''
				},
				privileges:[],
				isLoading:true
			}
		},
		components:{
			mucishead
		},
		onLoad(options) {
			// 加载loding
			
			// 	uni.showLoading({
			// 	    title: '加载中'
			// 	});
			
			// console.log(options.listId)
			list(options.listId).then((res) =>{
				if(res[1].data.code == '200'){
					// 获取接口数据 
					this.playlist = res[1].data.playlist;
					this.privileges = res[1].data.privileges;
					// 优化页面渲染效果
					this.isLoading = false;
					
					// store方法 获取下一个歌的ID
					this.$store.commit('INIT_TOPLISTIDS',res[1].data.playlist.trackIds);
					// 加载完成后隐藏loading
					 uni.hideLoading();
				}
			})
		},
		methods: {
			handelToDetail(songId){
				uni.navigateTo({
					url:'/pages/detail/detail?songId=' + songId
				})
			}
		}
	}
</script>

<style scoped>
	.list-head{
		display:flex;
		margin: 30rpx;
		
	}
	.list-head-img{
		width: 264rpx;
		height: 264rpx;
		border-radius: 30rpx;
		overflow: hidden;
		position: relative;
		margin-right:42rpx;
	}
	.list-head-img image{
		width: 100%;
		height:100%;
	}
	.list-head-img text{
		position:absolute;
		right: 8rpx;
		top:8rpx;
		color:#FFFFFF;
		font-size: 26rpx;
	}
	.list-head-text{
		flex:1;
		color: #f0f2f7;
	}
	.list-head-text view:nth-child(1){
		color:#FFFFFF;
		font-size: 34rpx;
	}
	.list-head-text view:nth-child(2){
		display: flex;
		margin: 20rpx 0;
		font-size:24rpx;
		align-items: center;
	}
	.list-head-text view:nth-child(2) image{
		width: 54rpx;
		height: 54rpx;
		border-radius: 50%;
		margin-right: 14rpx;
	}
	.list-head-text view:nth-child(3){
		line-height: 34rpx;
		font-size: 22rpx;
	}
	.list-share{
		display: flex;
		width: 330rpx;
		height: 74rpx;
		margin: 0 auto;
		background: rgba(0,0,0,0.4);
		border-radius: 37rpx;
		color: #fff;
		text-align: center;
		line-height: 74rpx;
		font-size: 28rpx;
		align-items: center;
	}
		
	.icon-share{
		width:45rpx;
		height: 45rpx;
		margin-right: 16rpx;
		
	}
	.list-music{
		background:#fff;
		border-radius:30rpx;
		margin-top: 40rpx;
		overflow: hidden;
	}
	.list-music-head{
		height: 50rpx;
		margin: 30rpx 0 70rpx 22rpx;
	}
	.list-music text:nth-child(1){
		height: 50rpx;
		font-size: 50rpx;
		
	}
	.list-music text:nth-child(2){
		font-size: 30rpx;
		margin: 0 10rpx 0 26rpx;
	}
	.list-music text:nth-child(3){
		font-size: 26rpx;
		color: #b2b2b2;
	}
	.list-music-item{
		display: flex;
		margin: 0 32rpx 66rpx 40rpx;
		align-items: center;
		color:#959595 ;
	}
	.list-music-top{
		width: 58rpx;
		font-size: 30rpx;
		line-height: 30rpx;
	}
	.list-music-song{
		flex: 1;
	}
	.list-music-song view:nth-child(1){
		font-size: 28rpx;
		color: #000;
		width: 70vw;
		white-space: nowrap;
		overflow: hidden;
		text-overflow: ellipsis;
	}
	.list-music-song view:nth-child(2){
		/* display: flex; */
		font-size: 20rpx;
		align-items: center;
		width: 70vw;
		white-space: nowrap;
		overflow: hidden;
		text-overflow: ellipsis;
		}
    .list-music-song view:nth-child(2) image{
		width: 32rpx;
		height: 20rpx;
		margin-right: 10rpx;
		
	}
	.list-music-item .itemiconfont{
		font-size: 60rpx !important;
		color: #c7c7c7 !important;
	}
</style>
